package com.tianqu.tms.www.transfer.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.transfer.controller.PNCInputResultController;
import com.tianqu.tms.www.transfer.viewhelper.CheckConfirmViewHelper;

public class PNCInputResultAction extends TmsAction {
	private Logger logger = Logger.getLogger(PNCInputResultAction.class);

	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		isToken(mapping, request);
		PNCInputResultController controller = new PNCInputResultController();
		controller.execute(uc);
		CheckConfirmViewHelper view = (CheckConfirmViewHelper) uc
				.getAttribute(TmsConstants.VIEWHELP);
		uc.removeAttribute(TmsConstants.VIEWHELP);

		String endTime = DateUtil.getATDay(new Date());

		view.setQy(new SimpleDateFormat("yyyy").format(new Date()));
		view.setQm(new SimpleDateFormat("MM").format(new Date()));
		view.setQd(new SimpleDateFormat("dd").format(new Date()));
		view.setEy(endTime.substring(0, 4));
		view.setEm(endTime.substring(5, 7));
		view.setEd(endTime.substring(8, 10));

		view.setPrintBsflag("1");
		uc.removeAttribute(TmsConstants.VIEWHELP);
		request.setAttribute(TmsConstants.VIEWHELP, view);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
